<%= page_title "#{@project.name} Build Command" %>
<% reused = @command.usage_ids.count > 1 %>
<%= breadcrumb @project, "Pre Build Command" %>

<section>
  <%= form_for @command, url: project_build_command_path(@project), html: { class: "form-horizontal", method: :patch } do |form| %>
    <%= render 'shared/errors', object: @command %>

    This command will run before a docker image is built.<br/>
    Use it to build artifacts and store them in $CACHE_DIR.<br/>
    Ideally execute a comitted <%= link_to "build.sh", "https://github.com/zendesk/samson/blob/master/docs/pre_build_command_example.md" %>
    that can be reused and debugged locally.<br/>

    <br/>

    <% if reused %>
      <p><b>This command is used multiple times, go <%= link_to "here", command_path(@command) %> to edit.</b></p>
    <% end %>

    <%= form.text_area :command, cols: 155, rows: [form.object.command.to_s.count("\n") + 1, 10].max, disabled: reused %>

    <% unless reused %>
      <%= form.submit "Save", class: "btn btn-primary" %> |
    <% end %>
    <%= link_to_history @command %>
  <% end %>
</section>
